package tag26_14_08.klasse_file;

import java.io.File;
import java.io.FileFilter;

public class Kf06_ElementAuflisten {

	public static void main(String[] args) {

		File[] roots =  File.listRoots();
		
		for(File rt : roots){
			System.out.println(rt);
		}
		
		System.out.println("-----------------------------------");
		File dir = roots[0];
		System.out.println("dir : "+ dir);
		
		System.out.println("-----------------------------------");
		String[] subItems = dir.list();
		for(String item : subItems){
			System.out.println(item);
		}
		
		System.out.println("-----------------------------------");
		File[] subFileOrDirs = dir.listFiles();
		
		for(File fileOrDir : subFileOrDirs){
			System.out.println(fileOrDir);
			String type = fileOrDir.isDirectory() ? "Verzeichnis":" Datei";
			System.out.println(" --> " + type);
		}
		
		System.out.println("------------Nur Verzeuchnis------------");
		
		for (File fileOrDir : subFileOrDirs) {
			if(fileOrDir.isDirectory()){
				System.out.println(fileOrDir);
			}
		}
		
		System.out.println("-------------Nur Dateien---------------");
		
		FileFilter filter = new FileFilter() {
			public boolean accept (File pathName){
				return pathName.isFile();
			}
		};
		
		File[] files = dir.listFiles(filter);
		
		for(File f : files){
			System.out.println(f);
		}
			
		
		
	}// end of main

}
